<%@ page language="java" contentType="text/html; charset=utf-8"   pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>客户信息管理</title>
<script src="<%=request.getContextPath() %>/js/jquery-1.8.2.js"></script>
</head>

<body>
<button id="show">添加客户</button><button>编辑客户</button><button id="delbut">删除选中</button>
<br>
<table width="90%" border="1" cellpadding="0" cellspacing="0">
	<tr>
	<td><input type="checkbox" id="SelAll" name="all"/></td> 
	<td>序号</td>
	<td>客户ID</td> 
	<td>客户名称</td> 
	<td>性别</td>
	<td>手机号码</td> 
	<td>联系地址</td>
	<td>邮箱</td>
	<td>QQ</td>
	<td>生成	APP</td>
	</tr>
	<c:forEach items="${clients}" var="c" varStatus="s">
	<tr id="0">
		<td name="box"><input type="checkbox" name="del" id="${c.id}"></td>
		<td name="index">${s.index+1}</td>
		<td name="id">${c.id }</td>
		<td name="name">${c.name}</td>
		<td name="sex">${c.sex==1?"男":"女"}</td>
		<td name="telNo">${c.telNo}</td>
		<td name="address">${c.address}</td>
		<td name="email">${c.email}</td>
		<td name="qq">${c.qq}</td>
		<td><a id="${c.id}" href="javascript:void(0)">查看</a></td>
	</tr>
	</c:forEach>
</table>
<br>
<div id="Add" style="display:none">
<form action="AddClient" method="post" >
客户名称:<input type="text" name="client.name" /><br>
性别:<input type="radio" name="client.sex" value="1"/>男
	<input type="radio" name="client.sex" value="0"/>女
<br>
手机号码:<input type="text" name="client.telNo" /><br>
联系地址:<input type="text" name="client.address" /><br>
邮箱:<input type="text" name="client.email" /><br>
QQ:<input type="text" name="client.qq" /><br>
<input type="submit" value="确定" /><input type="button" id="reset" value="取消" /><br>
</form>
</div>
<div style="display:none">
	<table>
		<tr></tr>
	</table>
</div>
</body>

<script>
$(function(){
	$("#show").click(function()
		{
		$("#Add").show();
		
	 });
	
	$("#reset").click(function()
		{
		$("#Add").hide();
		});
	
	$("#SelAll").click(function()
			{
		var obj=$(":checkbox[name='del']");
		obj.each(function()
			{
				$(this).prop('checked',!$(this).prop('checked'));
				
				});
			});
	$("#delbut").click(function()
			{
				var ids="";
				var obj=$(":checkbox[name='del']:checked");
				alert(obj.size());
				 obj.each(function()
					 {
					 ids=ids+$(this).attr('id')+',';
					});
					
				if(ids!="")
					location.href="DelClient?ids="+ids;
				
			});
	$("a").click(function()
			{
			var id=$(this).attr("id");
			$.ajax({
				type:"GET",
				url:'getClientApps',
				data:'id='+id,
				success:function(data)
				{
					 
					 
				}
			});
			});
			
})
</script>
</html>